package org.colcon.web.model;

import java.util.HashMap;
import java.util.Map;

import org.colcon.web.model.framework.IParam;

public class Param extends Item implements IParam
{
	private static final long serialVersionUID = 5323892913002630989L;
	
	private static final String
	
		// arguments
		DEFAULT = "defaults";
	
	private String value, defaultValue;
	
	public Param()
	{
		this(new HashMap<String, String>());
	}

	public Param(Map<String, String> args)
	{
		this(args.get(PARENT), args.get(ID), args.get(DEFAULT));
	}
	
	public Param(String parent, String id, String defaultValue)
	{
		this(parent, id, defaultValue, defaultValue);
	}
	
	public Param(String parent, String id, String defaultValue, String value)
	{
		super(parent, id);
		
		this.defaultValue = defaultValue;
		this.value = value;
	}

	public String getValue()
	{
		return value;
	}
	
	public String getDefaultValue()
	{
		return defaultValue;
	}
	
	public void setValue(Object value)
	{
		setValue(value.toString());
	}
	
	public void setValue(String value)
	{
		this.value = value;
	}
	
	public Param copy()
	{
		return new Param(getId(), defaultValue, value);
	}
}
